package com.example.userdome.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.userdome.pojo.Article;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface ArticleMapper extends BaseMapper<Article> {
    @Select("SELECT db_article.*, COUNT(db_like.id) AS like_count FROM db_article LEFT JOIN db_like ON db_article.id = db_like.articleid GROUP BY db_article.id")
    List<Article> selectArticleWithLikeCount();

}
